/**
 * 
 */
package com.app.mvc.action.rules;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.app.service.ICompetenceService;
import com.app.service.vo.CornCompetenceVo;
import com.app.util.ReuqestToVo;

/**
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value="/competence")
public class CompetenceAction {

	/**
	 * 
	 */
	public CompetenceAction() {
		// TODO Auto-generated constructor stub
		logger.info(this.getClass()+" loader");
	}
	
	private static Logger logger = Logger.getLogger(CompetenceAction.class);
	
	@Autowired
	private ICompetenceService competenceservie;

	/**
	 * 展现所有权限
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/manager.form")
	public String managerCompetence(HttpServletRequest request)
	{
		request.setAttribute("competence-list", this.competenceservie.getAllCornCompetenceVo());
		return "logins/admin/main-competence";
	}
	/**
	 * 增加新权限
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/add.form")
	public String addCompetence(HttpServletRequest request)
	{
		CornCompetenceVo vo = new CornCompetenceVo();
		ReuqestToVo.getVoFromRequest(request, vo);
		vo.setSing("1");
		this.competenceservie.addCornCompetenceVo(vo);
		return "forward:/competence/manager.form";
	}
	/**
	 * 通过id展现权限页面
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/show.form")
	public String showCompetence(@RequestParam("id") String id,HttpServletRequest request)
	{
		request.setAttribute("vo", this.competenceservie.getCornCompetenceVoById(id));
		return "logins/admin/competence/competence-show";
	}
	/**
	 * 更新权限信息 
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/update.form")
	public String updateCompetence(HttpServletRequest request)
	{
		CornCompetenceVo vo = new CornCompetenceVo();
		ReuqestToVo.getVoFromRequest(request, vo);
		this.competenceservie.updateCornCompetenceVo(vo);
		return "forward:/competence/show.form";
	}
	
	@RequestMapping(value="/delete.form")
	public String deltetCompetence(@RequestParam("id") String id)
	{
		CornCompetenceVo vo = new CornCompetenceVo();
		vo.setId(id);
		this.competenceservie.deleteCornCompetenceVo(vo);
		return "forward:/competence/manager.form";
	}
	public ICompetenceService getCompetenceservie() {
		return competenceservie;
	}

	public void setCompetenceservie(ICompetenceService competenceservie) {
		this.competenceservie = competenceservie;
	}

	
	
}
